/*     */ package nccloud.web.ic.pub.action;
/*     */ 
/*     */ import java.util.ArrayList;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import nc.pub.templet.converter.util.helper.ExceptionUtils;
/*     */ import nc.pubitf.org.cache.IOrgUnitPubService_C;
/*     */ import nc.vo.ic.general.define.ICBillBodyVO;
/*     */ import nc.vo.ic.general.define.ICBillFlag;
/*     */ import nc.vo.ic.general.define.ICBillVO;
/*     */ import nc.vo.ic.pub.util.CollectionUtils;
/*     */ import nc.vo.ic.pub.util.VOEntityUtil;
/*     */ import nc.vo.ml.NCLangRes4VoTransl;
/*     */ import nc.vo.pub.BusinessException;
/*     */ import nc.vo.pub.lang.UFDate;
/*     */ import nc.vo.scmpub.res.billtype.ICBillType;
/*     */ import nccloud.commons.lang.StringUtils;
/*     */ import nccloud.dto.ic.pub.entity.BillVOWithExtendInfo;
/*     */ import nccloud.dto.ic.pub.entity.QueryInfo;
/*     */ import nccloud.framework.core.json.IJson;
/*     */ import nccloud.framework.service.ServiceLocator;
/*     */ import nccloud.framework.web.action.itf.ICommonAction;
/*     */ import nccloud.framework.web.container.IRequest;
/*     */ import nccloud.framework.web.container.SessionContext;
/*     */ import nccloud.framework.web.json.JsonFactory;
/*     */ import nccloud.framework.web.ui.model.row.Cell;
/*     */ import nccloud.framework.web.ui.model.row.Row;
/*     */ import nccloud.framework.web.ui.pattern.billcard.BillCard;
/*     */ import nccloud.pubitf.ic.pub.service.IICBillVOQueryService;
/*     */ import nccloud.pubitf.scmpub.pub.util.BillSagaFieldsClearUtil;
/*     */ import nccloud.web.ic.pub.precision.ICBaseBillcardPrecisionHandler;
/*     */ import nccloud.web.ic.pub.utils.DealDisplayIsNullUtil;
/*     */ import nccloud.web.ic.ui.pattern.billcard.ICBillCardOperator;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class CopyAction
/*     */   implements ICommonAction
/*     */ {
/*     */   public Object doAction(IRequest request) {
/*  53 */     String str = request.read();
/*  54 */     IJson json = JsonFactory.create();
/*  55 */     QueryInfo info = (QueryInfo)json.fromJson(str, QueryInfo.class);
/*  56 */     ICBillVO[] aggvos = ((IICBillVOQueryService)ServiceLocator.find(IICBillVOQueryService.class)).query(
/*  57 */         getBilltype(), new String[] { info.getPk() });
/*     */     
/*  59 */     if (aggvos == null || aggvos.length == 0) {
/*  60 */       throw new RuntimeException(NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0", "04008027-0180"));
/*     */     }
/*     */ 
/*     */     
/*  64 */     if (!(aggvos[0] instanceof nc.vo.ic.m4d.entity.MaterialOutVO)) {
/*  65 */       ICBillBodyVO[] bodys = aggvos[0].getBodys();
/*  66 */       for (ICBillBodyVO body : bodys) {
/*  67 */         if (null != body.getCsourcebillhid()) {
/*  68 */           throw new RuntimeException(NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0", "04008027-0197"));
/*     */         }
/*     */       } 
/*     */     } 
/*     */ 
/*     */     
/*  74 */     BillSagaFieldsClearUtil.initAggregatedValueObject(aggvos);
/*     */     
/*  76 */     clearBillItems(aggvos);
/*  77 */     setDate(aggvos);
/*     */ 
/*     */     
/*  80 */     BillVOWithExtendInfo extendinfo = ((IICBillVOQueryService)ServiceLocator.find(IICBillVOQueryService.class)).queryBillExt(getBilltype(), info.getPk());
/*     */ 
/*     */     
/*  83 */     BillCard retcard = afterProcess(info.getPageid(), aggvos[0]);
/*  84 */     DealDisplayIsNullUtil.dealBillCardDisPlayIsNull(null, retcard);
/*     */ 
/*     */     
/*  87 */     Map<String, Object> retmap = new HashMap<String, Object>();
/*  88 */     retmap.put("billcard", retcard);
/*  89 */     retmap.put("isLocationManaged", Boolean.valueOf(extendinfo.isLocationManaged()));
/*  90 */     retmap.put("materialSerialMap", extendinfo.getMaterialSerialMap());
/*  91 */     retmap.put("materialSnunitMap", extendinfo.getMaterialSnunitMap());
/*  92 */     return retmap;
/*     */   }
/*     */   
/*     */   protected void setDate(ICBillVO[] aggvos) {
/*  96 */     if (aggvos == null || aggvos.length < 1) {
/*     */       return;
/*     */     }
/*     */ 
/*     */     
/* 101 */     IOrgUnitPubService_C service = (IOrgUnitPubService_C)ServiceLocator.find(IOrgUnitPubService_C.class);
/* 102 */     String pk_org = aggvos[0].getHead().getPk_org();
/* 103 */     String pk_org_v = null;
/*     */     try {
/* 105 */       UFDate data = new UFDate(SessionContext.getInstance().getClientInfo().getBizDateTime());
/* 106 */       pk_org_v = (String)service.getNewVIDSByOrgIDSAndDate(new String[] { pk_org }, data).get(pk_org);
/* 107 */     } catch (BusinessException e) {
/* 108 */       ExceptionUtils.wrapException(e);
/*     */     } 
/* 110 */     aggvos[0].getHead().setPk_org_v(pk_org_v);
/* 111 */     aggvos[0].getHead().setDbilldate(new UFDate(
/* 112 */           SessionContext.getInstance().getClientInfo()
/* 113 */           .getBizDateTime()));
/*     */     
/* 115 */     for (ICBillBodyVO body : aggvos[0].getBodys()) {
/* 116 */       if (body.getAttributeValue("nnum") != null) {
/* 117 */         body.setDbizdate(new UFDate(SessionContext.getInstance().getClientInfo()
/* 118 */               .getBizDateTime()));
/*     */       }
/*     */     } 
/*     */   }
/*     */   
/*     */   private void clearBillItems(ICBillVO[] aggvos) {
/* 124 */     String[] headClears = { "vbillcode", "cgeneralhid", "creator", "billmaker", "creationtime", "approver", "taudittime", "ts", "dmakedate", "tsourceheadts", "dbilldate", "modifier", "modifiedtime" };
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */     
/* 131 */     headClears = (String[])CollectionUtils.combineArrs(new String[][] { headClears, 
/* 132 */           getSpecialHeadClears() });
/* 133 */     VOEntityUtil.clearVOValue(aggvos[0].getHead(), headClears);
/* 134 */     aggvos[0].getHead().setFbillflag((Integer)ICBillFlag.FREE.value());
/* 135 */     aggvos[0].getHead().setStatus(2);
/* 136 */     String[] clearbodykeys = { "cgeneralbid", "cgeneralhid", "ccorrespondcode", "ccorrespondtype", "ccorrespondtranstype", "ccorrespondhid", "ccorrespondbid", "ccorrespondrowno", "ncorrespondnum", "ncorrespondastnum", "ncorrespondgrsnum", "ts", "tsourcebodyts", "tsourceheadts", "vbilltypeu8rm", "bhasiabill", "vexigencybid", "vexigencycode", "vexigencyhid", "vexigencyrowno", "vexigencytype", "csrc2billtype", "csrc2transtype", "csrc2billhid", "csrc2billbid", "csumid", "bassetcard", "bfixedasset", "vnotebody", "clocationid", "ntotalpicknum", "ntotaltrannum" };
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */     
/* 159 */     String[] snclearInfos = getSnClearInfos();
/* 160 */     String[] combinclearBodyKeys = (String[])CollectionUtils.combineArrs(new String[][] { clearbodykeys, snclearInfos, 
/* 161 */           getSpecialBodyClears() });
/* 162 */     ICBillBodyVO[] bodys = aggvos[0].getBodys();
/* 163 */     for (ICBillBodyVO body : bodys) {
/* 164 */       VOEntityUtil.clearVOValue(body, combinclearBodyKeys);
/* 165 */       body.setLocationVOs(null);
/* 166 */       body.setStatus(2);
/*     */     } 
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */   
/* 173 */   protected String[] getSpecialBodyClears() { return null; }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/* 179 */   protected String[] getSpecialHeadClears() { return null; }
/*     */ 
/*     */   
/*     */   private String[] getSnClearInfos() {
/* 183 */     List<String> list = new ArrayList<String>();
/* 184 */     list.add("vserialcode");
/* 185 */     list.add("pk_serialcode");
/* 186 */     list.add("csnqualitylevelid");
/* 187 */     String prefix = "vsndef";
/* 188 */     for (int i = 1; i <= 40; i++) {
/* 189 */       list.add(prefix + i);
/*     */     }
/* 191 */     return (String[])list.toArray(new String[list.size()]);
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/* 200 */   protected ICBillType getBilltype() { throw new RuntimeException(NCLangRes4VoTransl.getNCLangRes().getStrByID("4008027_0", "04008027-0198")); }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public BillCard afterProcess(String pageid, Object vo) {
/* 215 */     ICBillCardOperator operator = new ICBillCardOperator(pageid);
/* 216 */     BillCard retcard = operator.toCard(vo);
/*     */ 
/*     */     
/* 219 */     String ccurrencyid = (String)((ICBillVO)vo).getBody(0).getAttributeValue("ccurrencyid");
/* 220 */     if (ICBillType.SapplyBill.equals(((ICBillVO)vo).getHead().getBillType()) && 
/* 221 */       !StringUtils.isEmpty(ccurrencyid))
/*     */     {
/*     */       
/* 224 */       retcard.getBody().getModel().getListRows().stream().forEach(row -> {
/* 225 */             Cell cell = new Cell();
/* 226 */             cell.setValue(ccurrencyid);
/* 227 */             cell.setDisplay(ccurrencyid);
/* 228 */             row.addCell("ccurrencyid", cell);
/*     */           });
/*     */     }
/*     */ 
/*     */ 
/*     */     
/* 234 */     ICBaseBillcardPrecisionHandler handler = getPrecisionHandler(retcard);
/* 235 */     handler.process();
/*     */     
/* 237 */     return retcard;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/* 247 */   protected ICBaseBillcardPrecisionHandler getPrecisionHandler(BillCard retcard) { return new ICBaseBillcardPrecisionHandler(retcard); }
/*     */ }


/* Location:              E:\zhuhai_ncc\NCC2111\external\li\\uiic_nccloud.jar!/nccloud/web/ic/pub/action/CopyAction.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.0.7
 */